package com.xx.sg.controller;

import com.xx.sg.controller.req.SmsBody;
import com.xx.sg.sms.SmsService;
import com.xx.sg.util.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/sms")
@Tag(name = "短信Api", description = "短信Api")
public class SmsController {

    @Autowired
    private SmsService smsService;


//    @GetMapping("/sendSms")
//    @Tag(name = "发送短信", description = "发送短信")
//    public R sendSms(String tel) throws IOException {
//        return R.success(smsService.sendMsg(List.of(tel)));
//    }


    @PostMapping("/sendSms")
    @Tag(name = "发送短信", description = "发送短信")
    public R sendSms(@RequestBody SmsBody body) throws IOException {
        return R.success(smsService.sendMsg(body.getTels(), body.getContent()));
    }
}
